package com.lyshop.jinxiang.net;

import static com.lyshop.jinxiang.constants.Constant.TIME_OUT_EVENT_MSG;

import android.content.Context;
import android.text.TextUtils;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.lyshop.jinxiang.bean.AddressBean;
import com.lyshop.jinxiang.bean.BankListBean;
import com.lyshop.jinxiang.bean.BindCardBean;
import com.lyshop.jinxiang.bean.CalendarBean;
import com.lyshop.jinxiang.bean.CalendarDetail;
import com.lyshop.jinxiang.bean.CreateOrderResultBean;
import com.lyshop.jinxiang.bean.CreateShopProductBean;
import com.lyshop.jinxiang.bean.CredentialBean;
import com.lyshop.jinxiang.bean.EXPRecordBean;
import com.lyshop.jinxiang.bean.FollowGreatPeopleInfo;
import com.lyshop.jinxiang.bean.FollowListBean;
import com.lyshop.jinxiang.bean.FollowOrderBean;
import com.lyshop.jinxiang.bean.FollowUserBean;
import com.lyshop.jinxiang.bean.FreshListBean;
import com.lyshop.jinxiang.bean.GifBean;
import com.lyshop.jinxiang.bean.GoodsTicketInfoBean;
import com.lyshop.jinxiang.bean.HeaderSelectBean;
import com.lyshop.jinxiang.bean.HomeData;
import com.lyshop.jinxiang.bean.ImageItemBean;
import com.lyshop.jinxiang.bean.ImportDialogBean;
import com.lyshop.jinxiang.bean.ImportantBean;
import com.lyshop.jinxiang.bean.IntegralRecordBean;
import com.lyshop.jinxiang.bean.IntegralTicketBean;
import com.lyshop.jinxiang.bean.InvestSchoolGroupBean;
import com.lyshop.jinxiang.bean.NewsNoticeBean;
import com.lyshop.jinxiang.bean.OrderInfoBean;
import com.lyshop.jinxiang.bean.RechargeBean;
import com.lyshop.jinxiang.bean.RechargeSettingBean;
import com.lyshop.jinxiang.bean.RedBagBean;
import com.lyshop.jinxiang.bean.RetailOrderBean;
import com.lyshop.jinxiang.bean.RetailTicketBean;
import com.lyshop.jinxiang.bean.SellOrderInfoBean;
import com.lyshop.jinxiang.bean.ShopGoodsListBean;
import com.lyshop.jinxiang.bean.SignBean;
import com.lyshop.jinxiang.bean.TakeMoneyTipsBean;
import com.lyshop.jinxiang.bean.TicketBean;
import com.lyshop.jinxiang.bean.TransfeRecordBean;
import com.lyshop.jinxiang.bean.TurnCardBean;
import com.lyshop.jinxiang.bean.TxLiveTokenBean;
import com.lyshop.jinxiang.bean.UserBalanceBean;
import com.lyshop.jinxiang.bean.UserBankCardBean;
import com.lyshop.jinxiang.bean.UserIdCardBean;
import com.lyshop.jinxiang.bean.UserInfoBean;
import com.lyshop.jinxiang.bean.UserMessageBean;
import com.lyshop.jinxiang.bean.VersionBean;
import com.lyshop.jinxiang.bean.WelfareTaskBean;
import com.lyshop.jinxiang.constants.Constant;
import com.lyshop.jinxiang.utils.DataUtils;
import com.zc.mychart.model.GoodsAllBean;

import org.json.JSONException;
import org.json.JSONObject;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * onFailure中处理，如果不需要登录，token过期重新请求，如果需要登录，不要重新请求，直接返回到页面跳转到登录
 */
public class ApiImpl implements Api {
    private OkHttpEngine mOkHttpEngine;
    private Gson mGson;
    private Context mContext;

    public ApiImpl(Context context) {
        mOkHttpEngine = OkHttpEngine.getInstance(context);
        mGson = new Gson();
        mContext = context;
    }

    @Override
    public void getTxLiveSdk(String cert_no, String user_name, ApiCallBack<ApiResponse<TxLiveTokenBean>> callBack) {
        final Map<String, Object> map = new HashMap<>();
        map.put("cert_no", cert_no);
        map.put("user_name", user_name);

        try {
            mOkHttpEngine.postAsync(map, Api.TX_LIVE_SDK, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<TxLiveTokenBean>>() {
                    }.getType();
                    ApiResponse<TxLiveTokenBean> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getCosUpload(ApiCallBack<ApiResponse<CredentialBean>> callBack) {
        try {
            mOkHttpEngine.postAsync(null, Api.COS_UPLOAD, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<CredentialBean>>() {
                    }.getType();
                    ApiResponse<CredentialBean> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getBankList(String tcId, ApiCallBack<ApiResponse<List<BankListBean>>> callBack) {
        try {
            final Map<String, Object> map = new HashMap<>();
            map.put("tcId", tcId);
            mOkHttpEngine.postAsync(map, Api.BANK_LIST, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<List<BankListBean>>>() {
                    }.getType();
                    ApiResponse<List<BankListBean>> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getBanner(String type, ApiCallBack<ApiResponse<List<ImageItemBean>>> callBack) {
        try {
            final Map<String, Object> map = new HashMap<>();
            map.put("type", type);
            mOkHttpEngine.postAsync(map, Api.STATIC_HTML, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<List<ImageItemBean>>>() {
                    }.getType();
                    ApiResponse<List<ImageItemBean>> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }

    }

    @Override
    public void getRegisterCode(String mobile, final ApiCallBack<ApiResponse<Void>> callBack) {
        try {
            final Map<String, Object> map = new HashMap<>();
            map.put("mobile", mobile);
            mOkHttpEngine.postAsync(map, Api.REGISTER_CODE, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void register(String mobile, String code, String trade_password, String pushId, final ApiCallBack<ApiResponse<Void>> callBack) {
        try {
            final Map<String, Object> map = new HashMap<>();
            map.put("mobile", mobile);
            map.put("code", code);
            map.put("password", trade_password);
            map.put("push_id", pushId);
            map.put("oaid", DataUtils.getOAID(mContext));
            mOkHttpEngine.postAsync(map, Api.REGISTER, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void login(String mobile, String password, String pushId, final ApiCallBack<ApiResponse<UserInfoBean>> callBack) {
        try {
            final Map<String, Object> map = new HashMap<>();
            map.put("mobile", mobile);
            map.put("password", password);
            map.put("pushId", pushId);
            mOkHttpEngine.postAsync(map, Api.LOGIN, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<UserInfoBean>>() {
                    }.getType();
                    ApiResponse<UserInfoBean> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void authOneKey(String token, String pushId, final ApiCallBack<ApiResponse<UserInfoBean>> callBack) {
        try {
            final Map<String, Object> map = new HashMap<>();
            map.put("accessToken", token);
            map.put("pushId", pushId);
            mOkHttpEngine.postAsync(map, Api.AUTH_ONE_KEY, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<UserInfoBean>>() {
                    }.getType();
                    ApiResponse<UserInfoBean> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getUserDetail(ApiCallBack<ApiResponse<UserInfoBean>> callBack) {
        try {
            final Map<String, Object> map = new HashMap<>();
            mOkHttpEngine.postAsync(map, Api.USER_DETAIL, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<UserInfoBean>>() {
                    }.getType();
                    ApiResponse<UserInfoBean> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void resetPasswordCode(String mobile, int type, final ApiCallBack<ApiResponse<Void>> callBack) {
        try {
            final Map<String, Object> map = new HashMap<>();
            map.put("mobile", mobile);
            map.put("type", type + "");
            mOkHttpEngine.postAsync(map, Api.SYS_RESET_PASSWORD_CODE, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void resetPassword(String mobile, String code, String password, final ApiCallBack<ApiResponse<Void>> callBack) {
        try {
            final Map<String, Object> map = new HashMap<>();
            map.put("mobile", mobile);
            map.put("code", code);
            map.put("password", password);
            mOkHttpEngine.postAsync(map, Api.RESET_PASSWORD, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getAllList(final ApiCallBack<ApiResponse<List<GoodsAllBean>>> callBack) {
        try {
            final Map<String, Object> map = new HashMap<>();
            mOkHttpEngine.postAsync(map, Api.APP_LIST, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<List<GoodsAllBean>>>() {
                    }.getType();
                    ApiResponse<List<GoodsAllBean>> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getNewNoticeList(final ApiCallBack<ApiResponse<List<NewsNoticeBean>>> callBack) {
        try {
            mOkHttpEngine.postAsync(null, Api.NEW_NOTICE, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<List<NewsNoticeBean>>>() {
                    }.getType();
                    ApiResponse<List<NewsNoticeBean>> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getImportant(ApiCallBack<ApiResponse<ImportantBean>> callBack) {
        try {
            mOkHttpEngine.postAsync(null, Api.IMPORTANT, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<ImportantBean>>() {
                    }.getType();
                    ApiResponse<ImportantBean> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getOrderSquare(ApiCallBack<ApiResponse<List<SellOrderInfoBean>>> callBack) {
        try {
            mOkHttpEngine.postAsync(null, Api.ORDER_SQUARE, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<List<SellOrderInfoBean>>>() {
                    }.getType();
                    ApiResponse<List<SellOrderInfoBean>> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getRetailGoods(int page, ApiCallBack<ApiResponse<List<ShopGoodsListBean>>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("page", page);
        try {
            mOkHttpEngine.postAsync(map, Api.RETAIL_GOOD, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<List<ShopGoodsListBean>>>() {
                    }.getType();
                    ApiResponse<List<ShopGoodsListBean>> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getFollowList(int page, boolean openTime, String contract, boolean follow, String level, ApiCallBack<ApiResponse<List<FollowOrderBean>>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("page", page);
        map.put("openTime", openTime);
        map.put("contract", contract);
        map.put("follow", follow);
        map.put("level", level);
        try {
            mOkHttpEngine.postAsync(map, Api.FOLLOW_LIST, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<List<FollowOrderBean>>>() {
                    }.getType();
                    ApiResponse<List<FollowOrderBean>> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getGifList(ApiCallBack<ApiResponse<List<GifBean>>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        try {
            mOkHttpEngine.postAsync(map, Api.GIF_LIST, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<List<GifBean>>>() {
                    }.getType();
                    ApiResponse<List<GifBean>> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getKMap(String pro_code, String type, ApiCallBack<ApiResponse<List<List<Double>>>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("pro_code", pro_code);
        map.put("type", type);
        try {
            mOkHttpEngine.postAsync(map, Api.K_MAP, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<List<List<Object>>>>() {
                    }.getType();
                    ApiResponse<List<List<Double>>> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getPayList(ApiCallBack<ApiResponse<RechargeSettingBean>> callBack) {
        try {
            mOkHttpEngine.postAsync(null, Api.PAY_LIST, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<RechargeSettingBean>>() {
                    }.getType();
                    ApiResponse<RechargeSettingBean> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getCardList(String channel_id, ApiCallBack<ApiResponse<UserBankCardBean>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("channel_id", channel_id);
        try {
            mOkHttpEngine.postAsync(map, Api.CARD_LIST, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<UserBankCardBean>>() {
                    }.getType();
                    ApiResponse<UserBankCardBean> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void userSaving(int code, int amount, ApiCallBack<ApiResponse<RechargeBean>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("code", code);
        map.put("amount", amount);
        try {
            mOkHttpEngine.postAsync(map, Api.USER_SAVING, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<RechargeBean>>() {
                    }.getType();
                    ApiResponse<RechargeBean> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void uploadCert(String back, String front, ApiCallBack<ApiResponse<UserIdCardBean>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("back", back);
        map.put("front", front);
        try {
            mOkHttpEngine.postAsync(map, Api.UPLOAD_CERT, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<UserIdCardBean>>() {
                    }.getType();
                    ApiResponse<UserIdCardBean> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void uploadCertConfirm(String name, String request_id, ApiCallBack<ApiResponse<Void>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("name", name);
        map.put("request_id", request_id);
        try {
            mOkHttpEngine.postAsync(map, Api.UPLOAD_CERT_CONFIRM, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void createPro(OrderInfoBean order, ApiCallBack<ApiResponse<CreateOrderResultBean>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("goods_id", order.goods_id);
        map.put("trade_type", order.trade_type + "");
        map.put("amount", order.amount + "");
        map.put("use_ticket", order.use_ticket + "");
        map.put("target_profit", order.target_profit + "");
        map.put("stop_loss", order.stop_loss + "");
        map.put("is_first", order.isFirst);
        map.put("follow_order_id", TextUtils.isEmpty(order.follow_order_id) ? "0" : order.follow_order_id);
        map.put("follow_user_id", TextUtils.isEmpty(order.user_id) ? "0" : order.user_id);

        try {
            mOkHttpEngine.postAsync(map, Api.CREATE_PRO, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<CreateOrderResultBean>>() {
                    }.getType();
                    ApiResponse<CreateOrderResultBean> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getHoldOrderList(ApiCallBack<ApiResponse<List<OrderInfoBean>>> callBack) {
        try {
            mOkHttpEngine.postAsync(null, Api.HOLD_ORDER_LIST, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<List<OrderInfoBean>>>() {
                    }.getType();
                    ApiResponse<List<OrderInfoBean>> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getHistoryOrderList(int page, ApiCallBack<ApiResponse<List<OrderInfoBean>>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("page", page);
        try {
            mOkHttpEngine.postAsync(map, Api.HISTORY_ORDER_LIST, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<List<OrderInfoBean>>>() {
                    }.getType();
                    ApiResponse<List<OrderInfoBean>> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void sellOrder(String order_id, ApiCallBack<ApiResponse<Void>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("order_id", order_id);
        try {
            mOkHttpEngine.postAsync(map, Api.SELL_ORDER, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void editOrderInfo(String order_id, int target_profit, int stop_loss, ApiCallBack<ApiResponse<Void>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("order_id", order_id);
        map.put("target_profit", target_profit);
        map.put("stop_loss", stop_loss);
        try {
            mOkHttpEngine.postAsync(map, Api.EDIT_ORDER, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getInvestSchoolList(ApiCallBack<ApiResponse<List<InvestSchoolGroupBean>>> callBack) {
        try {
            mOkHttpEngine.postAsync(null, Api.USER_ASK, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<List<InvestSchoolGroupBean>>>() {
                    }.getType();
                    ApiResponse<List<InvestSchoolGroupBean>> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getRetailTicket(String goods_id, int sceneType, ApiCallBack<ApiResponse<GoodsTicketInfoBean>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("goods_id", goods_id);
        map.put("sceneType", sceneType);
        try {
            mOkHttpEngine.postAsync(map, Api.RETAIL_TICKET, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<GoodsTicketInfoBean>>() {
                    }.getType();
                    ApiResponse<GoodsTicketInfoBean> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    public void getWelfareList(ApiCallBack<ApiResponse<WelfareTaskBean>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        try {
            mOkHttpEngine.postAsync(map, Api.WELFARE_LIST, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<WelfareTaskBean>>() {
                    }.getType();
                    ApiResponse bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }

    }

    @Override
    public void signPost(ApiCallBack<ApiResponse<Void>> callBack) {
        try {
            mOkHttpEngine.postAsync(null, Api.SIGN_POST, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getTaskszIntegral(String list_id, String tasks_id, ApiCallBack<ApiResponse<Void>> callBack) {

        HashMap<String, Object> map = new HashMap<>();
        map.put("id", list_id);
        map.put("taskId", tasks_id);
        try {
            mOkHttpEngine.postAsync(map, Api.TASKS_POST, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void takeMoneyGetCode(ApiCallBack<ApiResponse<Void>> callBack) {
        try {
            mOkHttpEngine.postAsync(null, Api.WITHDRAW_CODE, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void takeMoneySubmit(String amount, String channel_id, String sms_code, ApiCallBack<ApiResponse<Void>> callBack) {

        HashMap<String, Object> map = new HashMap<>();
        map.put("amount", amount);
        map.put("channel_id", channel_id);
//        map.put("sms_code", sms_code);
        map.put("fundPwd", sms_code);

        try {
            mOkHttpEngine.postAsync(map, Api.WITHDRAW, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void takeMoneyTips(ApiCallBack<ApiResponse<TakeMoneyTipsBean>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        try {
            mOkHttpEngine.postAsync(map, Api.WITHDRAW_TIPS, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<TakeMoneyTipsBean>>() {
                    }.getType();
                    ApiResponse<TakeMoneyTipsBean> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void unbindCard(String channel_id, String code, ApiCallBack<ApiResponse<Void>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("channel_id", channel_id);
        map.put("sms_code", code);

        try {
            mOkHttpEngine.postAsync(map, Api.UNBIND_CARD, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void userRechargeConfirm(String bind_card_id, String order_no, String code, ApiCallBack<ApiResponse<Void>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("bind_card_id", TextUtils.isEmpty(bind_card_id) ? "" : bind_card_id);
        map.put("order_no", order_no);
        map.put("code", code);
        try {
            mOkHttpEngine.postAsync(map, Api.USER_SAVING_CONFIM, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }


    @Override
    public void userSaving(String code, String amount, String card_no, String phone, String card_user_name, String cert_no, String bank, ApiCallBack<ApiResponse<RechargeBean>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("code", code);
        map.put("amount", amount);
        map.put("card_no", card_no);
        map.put("phone", phone);
        map.put("card_user_name", card_user_name);
        map.put("cert_no", cert_no);
        map.put("bank", TextUtils.isEmpty(bank) ? "" : bank);

        try {
            mOkHttpEngine.postAsync(map, Api.USER_SAVING, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<RechargeBean>>() {
                    }.getType();
                    ApiResponse<RechargeBean> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    public void getIntegralTicketListData(ApiCallBack<ApiResponse<List<IntegralTicketBean>>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        try {
            mOkHttpEngine.postAsync(map, Api.INTEGRAL_TICKET, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<List<IntegralTicketBean>>>() {
                    }.getType();
                    ApiResponse<List<IntegralTicketBean>> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void exchangeTicket(String list_id, ApiCallBack<ApiResponse<Void>> callBack) {

        HashMap<String, Object> map = new HashMap<>();
        map.put("id", list_id);
        try {
            mOkHttpEngine.postAsync(map, Api.EXCHANGE_TICKET, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getSignDataList(ApiCallBack<ApiResponse<List<SignBean>>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        try {
            mOkHttpEngine.postAsync(map, Api.SIGN_DATA_LIST, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<List<SignBean>>>() {
                    }.getType();
                    ApiResponse<List<SignBean>> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    if (errorCode.equals(Constant.TOKEN_ERROR)) {
                        mOkHttpEngine.postAsync(null, Api.SIGN_DATA_LIST, this);
                    } else {
                        callBack.onFailure(errorCode, message);
                    }
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getUnbindCardCode(ApiCallBack<ApiResponse<Void>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        try {
            mOkHttpEngine.postAsync(map, Api.UNBIND_CARD_WITHDRAW_CODE, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    if (errorCode.equals(Constant.TOKEN_ERROR)) {
                        mOkHttpEngine.postAsync(null, Api.UNBIND_CARD_WITHDRAW_CODE, this);
                    } else {
                        callBack.onFailure(errorCode, message);
                    }
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getAddressList(ApiCallBack<ApiResponse<List<AddressBean>>> callBack) {
        try {
            mOkHttpEngine.postAsync(null, Api.ADDRESS_LIST, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<List<AddressBean>>>() {
                    }.getType();
                    ApiResponse<List<AddressBean>> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void createShopOrder(CreateShopProductBean bean, ApiCallBack<ApiResponse<Void>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("amount", bean.amount);
        map.put("address_id", bean.address_id);
        map.put("goods_id", bean.goods_id);
        map.put("couponId", bean.couponId);
        try {
            mOkHttpEngine.postAsync(map, Api.CREATE_RETAIL, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void deleteAddress(String id, ApiCallBack<ApiResponse<Void>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("id", id);
        try {
            mOkHttpEngine.postAsync(map, Api.DELETE_ADDRESS, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void createAddress(AddressBean mAddressBean, ApiCallBack<ApiResponse<Void>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("code", mAddressBean.code);
        map.put("mobile", mAddressBean.mobile);
        map.put("region", mAddressBean.region);
        map.put("name", mAddressBean.name);
        map.put("is_default", mAddressBean.is_default);
        map.put("address", mAddressBean.address);
        try {
            mOkHttpEngine.postAsync(map, Api.CREATE_ADDRESS, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void editAddress(AddressBean mAddressBean, ApiCallBack<ApiResponse<Void>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("code", mAddressBean.code);
        map.put("mobile", mAddressBean.mobile);
        map.put("region", mAddressBean.region);
        map.put("name", mAddressBean.name);
        map.put("is_default", mAddressBean.is_default);
        map.put("address", mAddressBean.address);
        map.put("id", mAddressBean.id);
        try {
            mOkHttpEngine.postAsync(map, Api.EDIT_ADDRESS, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void createProduct(CreateShopProductBean bean, ApiCallBack<ApiResponse<Void>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("amount", bean.amount);
        map.put("address_id", bean.address_id);
        map.put("order_id", bean.order_id);
        map.put("couponId", bean.couponId);
        try {
            mOkHttpEngine.postAsync(map, Api.PICK_RETAIL, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void bindCard(String channel_id, String card_no, String phone, String cert_no, String bank_code, String card_user_name, ApiCallBack<ApiResponse<BindCardBean>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("channel_id", channel_id);
        map.put("card_no", card_no);
        map.put("phone", phone);
        map.put("cert_no", cert_no);
        map.put("bank_code", bank_code);
        map.put("card_user_name", card_user_name);
        try {
            mOkHttpEngine.postAsync(map, Api.BIND_CARD, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<BindCardBean>>() {
                    }.getType();
                    ApiResponse<BindCardBean> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void confirmBindCard(String bind_card_id, String order_no, String check_rest, String sms_code, String base64Img, ApiCallBack<ApiResponse<Void>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("bind_card_id", bind_card_id);
        map.put("order_no", order_no);
        map.put("check_rest", check_rest);
        map.put("sms_code", sms_code);
        map.put("base64Img", base64Img);
        try {
            mOkHttpEngine.postAsync(map, Api.CONFIRM_BIND_CARD, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getTransfeRecord(String transferType, int page, ApiCallBack<ApiResponse<List<TransfeRecordBean>>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("page", page);
        map.put("transferType", transferType);
        try {
            mOkHttpEngine.postAsync(map, Api.TRANSFER_RECORD, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<List<TransfeRecordBean>>>() {
                    }.getType();
                    ApiResponse<List<TransfeRecordBean>> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getIntegralLog(String integral_type, String month, int page, ApiCallBack<ApiResponse<List<IntegralRecordBean>>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("page", page);
        map.put("month", month);
        map.put("integral_type", integral_type);
        map.put("page_count", 10);
        try {
            mOkHttpEngine.postAsync(map, Api.INTEGRAL_LOG, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<List<IntegralRecordBean>>>() {
                    }.getType();
                    ApiResponse<List<IntegralRecordBean>> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getMsgList(int page, ApiCallBack<ApiResponse<List<UserMessageBean>>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("page", page);
        try {
            mOkHttpEngine.postAsync(map, Api.MESSAGE_LIST, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<List<UserMessageBean>>>() {
                    }.getType();
                    ApiResponse<List<UserMessageBean>> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getExperienceLog(int page, ApiCallBack<ApiResponse<List<EXPRecordBean>>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("page", page);
        map.put("page_count", 10);
        try {
            mOkHttpEngine.postAsync(map, Api.EXPERIENCE_LOG, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<List<EXPRecordBean>>>() {
                    }.getType();
                    ApiResponse<List<EXPRecordBean>> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getUserTicketList(String type, int page, ApiCallBack<ApiResponse<List<TicketBean>>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("page", page);
        map.put("type", type);
        map.put("page_count", 10);
        try {
            mOkHttpEngine.postAsync(map, Api.USER_TICKET, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<List<TicketBean>>>() {
                    }.getType();
                    ApiResponse<List<TicketBean>> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getAvatarList(ApiCallBack<ApiResponse<List<HeaderSelectBean>>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        try {
            mOkHttpEngine.postAsync(map, Api.AVATAR_LIST, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<List<HeaderSelectBean>>>() {
                    }.getType();
                    ApiResponse<List<HeaderSelectBean>> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void editUserAvatar(String header_id, ApiCallBack<ApiResponse<Void>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("header_id", header_id);
        try {
            mOkHttpEngine.postAsync(map, Api.EDIT_AVATAR, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void editUserNickName(String nickname, ApiCallBack<ApiResponse<Void>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("nickname", nickname);
        try {
            mOkHttpEngine.postAsync(map, Api.EDIT_NICKNAME, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getRetailOrderList(String status, String orderType, int page, ApiCallBack<ApiResponse<List<RetailOrderBean>>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("status", status);
        map.put("orderType", orderType);
        map.put("page", page);
        try {
            mOkHttpEngine.postAsync(map, Api.RETAIL_ORDER, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<List<RetailOrderBean>>>() {
                    }.getType();
                    ApiResponse<List<RetailOrderBean>> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void confirmOrder(String order_id, ApiCallBack<ApiResponse<Void>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("order_id", order_id);
        try {
            mOkHttpEngine.postAsync(map, Api.CONFIRM_PRODUCT, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getMyFollowOrder(int page, String userId, ApiCallBack<ApiResponse<List<FollowOrderBean>>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("hold", true);
        map.put("userId", userId);
        map.put("page", page);
        try {
            mOkHttpEngine.postAsync(map, Api.MY_FOLLOW_ORDER, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<List<FollowOrderBean>>>() {
                    }.getType();
                    ApiResponse<List<FollowOrderBean>> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void followUser(FollowUserBean bean, ApiCallBack<ApiResponse<Void>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("user_id", bean.userId);
        map.put("type", bean.type);
        try {
            mOkHttpEngine.postAsync(map, Api.FOLLOW_USER, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void followList(int type, int page, ApiCallBack<ApiResponse<List<FollowListBean>>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("type", type);
        map.put("page", page);
        try {
            mOkHttpEngine.postAsync(map, Api.FOLLOW_USER_List, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<List<FollowListBean>>>() {
                    }.getType();
                    ApiResponse<List<FollowListBean>> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getRetailTicketList(ApiCallBack<ApiResponse<List<RetailTicketBean>>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("type", "1");
        map.put("page", "1");
        try {
            mOkHttpEngine.postAsync(map, Api.RETAIL_TICKET_LIST, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {

                    Type type = new TypeToken<ApiResponse<List<RetailTicketBean>>>() {
                    }.getType();
                    ApiResponse<List<RetailTicketBean>> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void editPushMsg(String msgIds, ApiCallBack<ApiResponse<Void>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("msgIds", msgIds);
        try {
            mOkHttpEngine.postAsync(map, Api.MESSAGE_EDIT, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void loopPushList(ApiCallBack<ApiResponse<FreshListBean>> callBack) {
        try {
            mOkHttpEngine.postAsync(null, Api.PUSH_LIST, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<FreshListBean>>() {
                    }.getType();
                    ApiResponse<FreshListBean> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void uploadPushId(String id, ApiCallBack<ApiResponse<Void>> callBack) {
        HashMap<String, Object> map = new HashMap<>();
        map.put("id", id);
        try {
            mOkHttpEngine.postAsync(map, Api.PUSH_SUCCESS, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void updateVersion(String type, ApiCallBack<ApiResponse<VersionBean>> callBack) {
        try {
            final Map<String, Object> map = new HashMap<>();
            map.put("type", type);
            mOkHttpEngine.postAsync(map, Api.UPDATE_VERSION, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<VersionBean>>() {
                    }.getType();
                    ApiResponse<VersionBean> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getFollowGreatPeopleInfo(String userId, final ApiCallBack<ApiResponse<FollowGreatPeopleInfo>> callBack) {
        Map<String, Object> map = new HashMap<>();
        map.put("user_id", userId);
        try {
            mOkHttpEngine.postAsync(map, Api.FOLLOW_ORDER_GREAT_INFO, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<FollowGreatPeopleInfo>>() {
                    }.getType();
                    ApiResponse<FollowGreatPeopleInfo> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getCalendarData(String date, final ApiCallBack<List<CalendarBean>> callBack) {
        String url = "https://rili-open-api.jin10.com/get/data?category=cj&end_date=" + date + "&start_date=" + date;
        mOkHttpEngine.getAsync(url, new ApiCallBack<String>() {
            @Override
            public void onSuccess(String data) {
                try {
                    JSONObject objectData = new JSONObject(data);
                    String info = objectData.get("data").toString();
                    Type type = new TypeToken<List<CalendarBean>>() {
                    }.getType();
                    List<CalendarBean> bean = mGson.fromJson(info, type);
                    callBack.onSuccess(bean);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onFailure(String errorCode, String message) {
                callBack.onFailure(errorCode, message);
            }
        });
    }

    @Override
    public void getCalendarDetail(String id, final ApiCallBack<CalendarDetail> callBack) {
        String url = "https://rili-open-api.jin10.com/getDataById?id=" + id;
        mOkHttpEngine.getAsync(url, new ApiCallBack<String>() {
            @Override
            public void onSuccess(String data) {
                try {
                    JSONObject objectData = new JSONObject(data);
                    String info = objectData.get("data").toString();
                    Type type = new TypeToken<CalendarDetail>() {
                    }.getType();
                    CalendarDetail bean = mGson.fromJson(info, type);
                    callBack.onSuccess(bean);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void onFailure(String errorCode, String message) {
                callBack.onFailure(errorCode, message);
            }
        });
    }

    @Override
    public void getImportNoticeDialog(ApiCallBack<ApiResponse<ImportDialogBean>> callBack) {
        try {
            mOkHttpEngine.postAsync(null, Api.NOTICE_UNREAD, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<ImportDialogBean>>() {
                    }.getType();
                    ApiResponse<ImportDialogBean> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }

    }

    @Override
    public void readNotice(String id, ApiCallBack<ApiResponse<Void>> callBack) {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        try {
            mOkHttpEngine.postAsync(map, Api.NOTICE_READ, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getRedBagList(ApiCallBack<ApiResponse<List<RedBagBean>>> callBack) {
        try {
            mOkHttpEngine.postAsync(null, Api.REDBAG_LIST, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<List<RedBagBean>>>() {}.getType();
                    ApiResponse<List<RedBagBean>> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void drawRedBag(ApiCallBack<ApiResponse<Void>> callBack) {
        try {
            mOkHttpEngine.postAsync(null, Api.REDBAG_DRAW, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getTurnCardList(ApiCallBack<ApiResponse<TurnCardBean>> callBack) {
        try {
            mOkHttpEngine.postAsync(null, Api.TURN_CARD_LIST, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<TurnCardBean>>() {}.getType();
                    ApiResponse<TurnCardBean> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void drawTurnCard(ApiCallBack<ApiResponse<TurnCardBean>> callBack) {
        try {
            mOkHttpEngine.postAsync(null, Api.TURN_CARD_DRAW, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<TurnCardBean>>() {}.getType();
                    ApiResponse<TurnCardBean> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void adPost(ApiCallBack<ApiResponse<Void>> callBack) {
        try {
            mOkHttpEngine.postAsync(null, Api.AD_POST, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getHomeData(String type, ApiCallBack<ApiResponse<HomeData>> callBack) {
        Map<String, Object> map = new HashMap<>();
        map.put("type", type);
        try {
            mOkHttpEngine.postAsync(map, Api.HOME_DATA, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<HomeData>>() {}.getType();
                    ApiResponse<HomeData> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getUserBalance(ApiCallBack<ApiResponse<UserBalanceBean>> callBack) {
        try {
            mOkHttpEngine.postAsync(null, Api.USER_BALANCE, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    Type type = new TypeToken<ApiResponse<UserBalanceBean>>() {}.getType();
                    ApiResponse<UserBalanceBean> bean = mGson.fromJson(data, type);
                    callBack.onSuccess(bean);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void getPayPasswordCode(ApiCallBack<ApiResponse<Void>> callBack) {
        try {
            final Map<String, Object> map = new HashMap<>();
            mOkHttpEngine.postAsync(map, Api.SYS_GET_PAY_PASSWORD_CODE, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }

    @Override
    public void setPayPassword(String code, String password, String confirmPasswrod, final ApiCallBack<ApiResponse<Void>> callBack) {
        try {
            final Map<String, Object> map = new HashMap<>();
            map.put("captcha", code);
            map.put("fundPwd", password);
            map.put("confirmFundPwd", confirmPasswrod);
            mOkHttpEngine.postAsync(map, Api.SET_PAY_PASSWORD, new ApiCallBack<String>() {
                @Override
                public void onSuccess(String data) {
                    callBack.onSuccess(null);
                }

                @Override
                public void onFailure(String errorCode, String message) {
                    callBack.onFailure(errorCode, message);
                }
            });
        } catch (Exception e) {
            callBack.onFailure(Constant.FAILED, TIME_OUT_EVENT_MSG);
            e.printStackTrace();
        }
    }
}
